﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MVCDemo.Models;

namespace MVCDemo.Controllers
{
    public class EmployeeController : Controller
    {
        // The input parameter should be exactly the same with the parameter in the view.
        public ActionResult Index(int departmentid)
        {
            EmployeeContext employeeContext = new EmployeeContext();
            List<Employee> emp = employeeContext.Employees.Where(e => e.DepartmentId == departmentid).ToList();
            return View(emp);
        }

        public ActionResult Details(int id)
        {
            EmployeeContext employeeContext = new EmployeeContext();
            Employee employee = employeeContext.Employees.Single(emp => emp.EmployeeId == id);

            return View(employee);
        }

        public ActionResult ManagersDetails()
        {
            Managers mgr = new Managers()
            {
                Id = 1,
                Name = "Jeff",
                Position = "CEO"
            };

            return View(mgr);
        }

    }
}
